home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-04-01 | 4.9 KB | 91 lines | [TEXT/GEOL] |
- Item 2824234 5-March-91 14:28PST
-
- From: ALGER Alger, Jeff,VCA
-
- To: D4727 Philmont SW Mill, Jesse Feiler,PAS
- MACAPP.TECH$ MacApp Technical
-
- ------------------------------------------------------------------------------
-
- Sub: Another MA3 opinion (longer)
-
- MacApp.Techers: I don't know whether anyone actually received the following, as
- I am battling a flaky modem. Here goes again.
- -------------------------------------------------------------------------------
-
- Jesse,
-
- "'Fess up, Jeff. Don't you (like the rest of us) leave inheritance and
- polymorphism in in designing the run-time environment?" All right, I confess…
- I do form abstractions during analysis and design. I do not, however, form
- classes until the last possible moment. There is a subtle but important
- difference. If objects X and Y share certain properties, I can describe the
- common features (an abstraction) during analysis and design without imposing a
- decision that this will ultimately translate into an ancestor class. Why?
-
- • There are often overlapping abstractions, not all of which can or should be
- reflected in a class hierarchy, which are nonetheless useful in describing the
- design of the program.
-
- • A related issue is that the class hierarchy is limited by the language chosen
- (e.g., multiple inheritance), while abstractions are not. Design should be
- language-independent wherever possible; the language and the use of its
- features are implementation decisions.
-
- • There are many ways to implement abstractions. There is a strict
- equivalence, from a theoretical point of view, between inheritance and
- communications with "helper" objects. If class A has properties I need in an
- instance of class B, I can either associate an instance of A or inherit from A
- and achieve the same end result either way. This is the basis of the classic
- multiple inheritance workaround. I can also construct an argument that #define
- macros, MPW editing scripts and even simple copy-paste editing can be used to
- implement abstractions, independent of the class hierarchy. And, of course, I
- still have IF-ELSE and CASE available (no, I don't think they've been
- eliminated by OOP, but that's an intriguing line of thought I'll return to
- shortly). With all of these ways of implementing a single concept, I should be
- able to describe the concept and leave the decision of how to implement it as a
- separate issue.
-
- • People deal well with abstractions, but not necessarily class hierarchies.
- Consult "Women, Fire and Dangerous Things" by George Lakoff if you want to see
- the evidence. Classes are not really all that great at capturing semantics,
- even though objects are.
-
- • Closer to home, one of the biggest benefits of MacApp is that you don't have
- to worry about the class library until your design is pretty well set. When
- you are ready to design the class hierarchy, MacApp will be there with the
- right features or pretty close to it. The analysis and design process should
- not be "here are the MacApp classes, what can we make of them?" but "here are
- the concrete objects and interface we want, what MacApp classes help us build
- them?"
-
- As to your three classes of methods, how about this for an intellectual basis
- (I don't know how elegant, however). There are four things you can inherit: a
- public interface, a private (protected, in C++ terms) interface, relationships
- to other objects, and behaviors (implementations of methods). This applies to
- individual methods and to classes. (Classes can also inherit data.) Methods
- which MUST be overridden exist only to pass along an interface. Methods which
- call INHERITED are extensions to a behavior, but leave the basic behavior
- intact and, by extension, also preserve relationships. Methods which are
- completely overridden and do not call INHERITED are the dangerous ones and
- should be avoided where possible; they may or may not preserve relationships
- and you can't tell in advance how they will be used. These are the "methods
- which may or may not be completely or partially overridden or perhaps not even
- called but no one can tell for sure in advance or perhaps not even in the
- finished program and I'm just going to chuck the whole program and go fishing."
-
- Returning to Dijkstra, you are right that inheritance and polymorphism have the
- hallmarks of IF-THEN and CASE constructs, branching on the type. However, the
- point about eliminating GOTOs is to limit the number of ways to reach a given
- line of code, thereby making it easier to prove or test correctness. If we
- eliminate IF-THEN and CASE in such a way that we can't tell how a given line of
- code can be reached, we have jumped backward, not forward. And I certainly
- take issue with the assertion that compiling and running (once) properly
- translates into functioning code; if anything, OOP code is MORE difficult to
- test, line for line, not less.
-
- Buried in my own abstractions,
- I remain,
- Jeff Alger
-
-